package com.tuling.spring;

import com.tuling.UserInterface;
import com.tuling.UserService;
import org.springframework.aop.AfterReturningAdvice;
import org.springframework.aop.framework.ProxyFactory;

/**
 * AfterReturningAdvice Demo
 */
public class ProxyFactoryDemoD {

	public static void main(String[] args) {
		ProxyFactory proxyFactory = new ProxyFactory(new UserService());
		proxyFactory.addAdvice((AfterReturningAdvice) (returnValue, method, args1, target) -> {
			if (method.getName().equals("test")) {
				System.out.println("After Returning...");
			}
		});
		UserInterface userInterface = (UserInterface) proxyFactory.getProxy();
		userInterface.test();
	}
}
